/**
 * <p>Copyright: Copyright (c) 2014</p>
 * <p>Company: ---Technology Co. Ltd</p>
 * <p>2014-4-30</p>
 * @author Jan.Zhang
 */
package com.xianl.busiplat.dwz;

import org.apache.commons.lang3.StringUtils;


/** 
 * desc:
 * <p>author: Jan.Zhang </p>
 * date: 2014-4-30
 */
public class AjaxObject {

	// 状态码
	public final static int STATUS_CODE_SUCCESS = 200;
	public final static int STATUS_CODE_FAILURE = 300;
	public final static int STATUS_CODE_TIMEOUT = 301;
	public final static int STATUS_CODE_FORBIDDEN = 403;
	// callbackType类型
	public final static String CALLBACK_TYPE_CLOSE_CURRENT = "closeCurrent";
	public final static String CALLBACK_TYPE_FORWARD = "forward";
	public final static String CALLBACK_TYPE_SMPRELOADLIST = "smpreloadList";
	private int statusCode = STATUS_CODE_SUCCESS;
	private String message = "";
	private String navTabId = "";
	private String forwardUrl = "";
	private String rel = "";
	private String callbackType = CALLBACK_TYPE_CLOSE_CURRENT;

	public AjaxObject () {
	}

	public AjaxObject (String message ) {
		this.message = message;
	}

	/**
	 * 构造函数
	 * @param statusCode
	 * @param message
	 * @param callbackType
	 */
	public AjaxObject (int statusCode , String message , String callbackType ) {
		this.statusCode = statusCode;
		this.message = message;
		this.callbackType = callbackType;
	}

	/**
	 * 构造函数
	 * @param statusCode
	 * @param message
	 * @param forwardUrl
	 * @param rel
	 * @param callbackType
	 */
	public AjaxObject (int statusCode , String message , String navTabId , String forwardUrl , String rel ,
			String callbackType ) {
		this.statusCode = statusCode;
		this.message = message;
		this.navTabId = navTabId;
		this.forwardUrl = forwardUrl;
		this.rel = rel;
		this.callbackType = callbackType;
	}

	/**
	 * 返回 statusCode 的值
	 * @return statusCode
	 */
	public int getStatusCode() {
		return statusCode;
	}

	/**
	 * 设置 statusCode 的值
	 * @param statusCode
	 */
	public void setStatusCode(int statusCode) {
		this.statusCode = statusCode;
	}

	/**
	 * 返回 message 的值
	 * @return message
	 */
	public String getMessage() {
		return message;
	}

	/**
	 * 设置 message 的值
	 * @param message
	 */
	public void setMessage(String message) {
		this.message = message;
	}

	/**
	 * 返回 forwardUrl 的值
	 * @return forwardUrl
	 */
	public String getForwardUrl() {
		return forwardUrl;
	}

	/**
	 * 设置 forwardUrl 的值
	 * @param forwardUrl
	 */
	public void setForwardUrl(String forwardUrl) {
		this.forwardUrl = forwardUrl;
	}

	/**
	 * 返回 rel 的值
	 * @return rel
	 */
	public String getRel() {
		return rel;
	}

	/**
	 * 设置 rel 的值
	 * @param rel
	 */
	public void setRel(String rel) {
		this.rel = rel;
	}

	/**
	 * 返回 callbackType 的值
	 * @return callbackType
	 */
	public String getCallbackType() {
		return callbackType;
	}

	/**
	 * 设置 callbackType 的值
	 * @param callbackType
	 */
	public void setCallbackType(String callbackType) {
		this.callbackType = callbackType;
	}

	/**
	 * 返回 navTabId 的值
	 * @return navTabId
	 */
	public String getNavTabId() {
		return navTabId;
	}

	/**
	 * 设置 navTabId 的值
	 * @param navTabId
	 */
	public void setNavTabId(String navTabId) {
		this.navTabId = navTabId;
	}

	/**
	 * @return
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		StringBuffer buffer = new StringBuffer();
		buffer.append("{");
		buffer.append("\"statusCode\":\"" + statusCode + "\"");
		if(StringUtils.isNotBlank(message) ) {
			buffer.append("," + "\"message\":\"" + message + "\"");
		}
		if(StringUtils.isNotBlank(navTabId) ) {
			buffer.append("," + "\"navTabId\":\"" + navTabId + "\"");
		}
		if(StringUtils.isNotBlank(rel) ) {
			buffer.append("," + "\"rel\":\"" + rel + "\"");
		}
		if(StringUtils.isNotBlank(callbackType) ) {
			buffer.append("," + "\"callbackType\":\"" + callbackType + "\"");
		}
		if(StringUtils.isNotBlank(forwardUrl) ) {
			buffer.append("," + "\"forwardUrl\":\"" + forwardUrl + "\"");
		}
		// .append("\"message\":\"" + message + "\",")
		// .append("\"navTabId\":\"" + navTabId + "\",")
		// .append("\"rel\":\"" + rel + "\",")
		// .append("\"callbackType\":\"" + callbackType + "\",")
		// .append("\"forwardUrl\":\"" + forwardUrl + "\"")
		buffer.append("}");
		return buffer.toString();
	}
}
